Skip to main content

Managing Aliases in Your App

Aliases are a way to manage multiple user identities or profiles within your app. Each alias can be incognito or standard, and the app offers options to enable, disable, or delete these aliases. Aliases can be managed across multiple devices, providing users with a seamless experience.

Getting Started

To use the alias management feature in your app, you will need to initialize an agent using the initializeAgent function. This agent provides access to alias management functions such as creating, enabling, disabling, deleting, and syncing aliases.

Adding an Alias

  1. Initialize the Agent: Ensure that you have an initialized agent instance to perform actions.
  2. Add an Alias: Call the addAlias function, providing the necessary alias details.
  3. Set Display Name: After adding the alias, set an appropriate display name.

Code Example:

const onSetAlias = async (alias: string, isIncognito: boolean) => {
setAlias(alias);
setIncognito(isIncognito);
setAddAliasModalVisible(false);
setAddDisplaynameModalVisible(true);
};

const onSetDisplayName = async (displayName: string) => {
const createAlias: CreateAlias = { alias: alias, type: AliasType.Alias, displayName: displayName.trim(), isIncognito: incognito };
await addAlias(createAlias);
await loadAliases();
};

For more details, check out the implementation of addAlias.

Getting Aliases

Getting Current Aliases

To fetch aliases associated with the current device:

const getCurrentAliases = async () => {
const agent = await initializeAgent();
if (!agent) throw new Error('Agent not initialized');
const result = await agent.aliasManager.getList(AliasConnectionType.Current);
if (result.isSuccessful && result.result) return result.result;
else throw new Error(result.error);
};

For more details, check out the implementation of getList.

Getting Other Aliases

To fetch aliases stored on other devices:

const getOtherAliases = async () => {
const agent = await initializeAgent();
if (!agent) throw new Error('Agent not initialized');
const result = await agent.aliasManager.getList(AliasConnectionType.Others);
if (result.isSuccessful && result.result) return result.result;
else throw new Error(result.error);
};

Enabling and Disabling Aliases

To enable or disable aliases, follow these steps:

  1. Select an Alias: Pick an alias from the list in the app.
  2. Enable/Disable Alias: Call the appropriate function (enableAlias or disableAlias).

Code Example:

const onActivate = async () => {
if (selectedAlias) {
await enableAlias(selectedAlias.id);
await loadAliases();
}
};

const onDeactivate = async () => {
if (selectedAlias) {
await disableAlias(selectedAlias.id);
await loadAliases();
}
};

Refer to the detailed implementations of enableAlias and disableAlias.

Deleting an Alias

To delete an alias:

  1. Select an Alias: Choose an alias from the list.
  2. Delete the Alias: Call the deleteAlias function.

Code Example:

const onDelete = async () => {
if (selectedAlias) {
await deleteAlias(selectedAlias.id);
await loadAliases();
}
};

See more about deleting an alias in the documentation for deleteAlias.

Moving Aliases to Current Wallet

If you want to move an alias to the current wallet, use the moveAliastoCurrentWallet function.

Code Example:

const handleAssociate = async () => {
if (selectedAlias) {
await moveAliastoCurrentWallet(selectedAlias.id);
await loadAliases();
}
};

For detailed guidance, see moveAliastoCurrentWallet.

Syncing Aliases

Syncing aliases ensures that all the aliases are up-to-date across all devices. This operation should be performed periodically or whenever significant changes are made.

Code Example:

const syncAliases = async () => {
const result = await agent.aliasManager.sync();
if (result.isSuccessful) {
// handle success
} else {
// handle error
}
};

Check the full implementation of syncAliases.


Function Details

Each of the functions mentioned here is documented with detailed descriptions and examples. For further reference and to explore each function's inner workings, click on the respective links:

You have now completed the quickstart guide for integrating Aliases into your app.

Additional Reading

Managers

Managers are classes responsible for managing various aspects of the One37ID SDK.

Before accessing any managers, you must first initialize the agent. After the agent is initialized, you can access the various managers.

To initialize the agent, use the following code:

const agent = await initializeAgent();

1. Contact Manager

The Contact Manager is responsible for managing all tasks related to connections.

2. Credential Manager

Credential Manager is a key component for managing verifiable credentials within the One37ID platform.

3. Alias Manager

The Alias Manager in the One37ID SDK is responsible for managing aliases, which are identifiers that can be used to represent entities (such as users or organizations) within the system.

4. Notification Manager

The Notification Manager is responsible for handling all tasks related to notifications within the system

X

Graph View